package calc;

import java.util.ArrayList;
import java.util.List;

import workflow.core.WorkflowRunableElement;
import workflow.dto.WorkflowMessage;

public class SubtractionRunableCommand extends WorkflowRunableElement{

	public SubtractionRunableCommand(String name) {
		super(name);
	}

	@Override
	public void excecute() {
		// pobieranie wartosci
		WorkflowMessage message = inMessages.get(0);
		int first = (Integer) message.getValues().get(1);
		int second =  (Integer) message.getValues().get(2);
		
		// wlasciwe dzialanie
		int result = first - second;
		
		// tworzenie wiadomosci wyjsciowej
		WorkflowMessage out = new WorkflowMessage(getClass());
		List<Object> values = new ArrayList<Object>();
		values.add(result);
		out.setValues(values);
		outMessages.add(out);
	}

}
